<template>
  <work-template v-model="detailForm" @submitOn="submitOn" @closeSelectedTag="closeSelectedTag" :butShow="isEdit">
    <div slot="form">
      <basic-info :isDownload="isDownload" :detailForm="detailForm"/>
      <shop-insurace v-model="detailForm" />
      <other :detailForm="detailForm" :isEdit="true" :isShow="true"/>
    </div>

  </work-template>
</template>

<script>
import {addInsuranceList, getDataTest, getWorkDetails} from "@/api/cwgd/insureApi.js";

export default {
  name: "insureHandle",//处理
  components: {
    basicInfo: () => import('../components/carWorkOrder/basicInfo.vue'),
    shopInsurace: () => import('../components/carWorkOrder/shopInsurace.vue'),
    other: () => import('../components/carWorkOrder/other.vue')
  },
  data() {
    return {
      isDownload: true,
      detailForm: {},
      isEdit: true,
      inspectDetail: {},
      businessVoList: [],// 我司购买保险套餐
    };
  },
  computed: {},
  watch: {},

  created() {
    this.handleDetail()
  },
  mounted() {
  },
  methods: {
    //获取详情 详情页
    handleDetail(id) {
      //工单id
      if (this.$route.query.businessDataId) {
        getWorkDetails(this.$route.query.businessDataId).then(res => {
          if (res.code === 200) {
            this.detailForm = res.data || {}
          }
        })
      }else{
        getDataTest(this.$route.query).then(res => {
          this.inspectDetail = res
          this.businessVoList = this.inspectDetail.businessList
          for (const key in this.inspectDetail) {
            this.$set(this.detailForm, key, this.inspectDetail[key]);
          }
        });
      }

    },

    //提交表单
    submitOn() {
      return
      this.closeSelectedTag(this.$route)
    },

    //
    closeSelectedTag(view) {
      this.$tab.closePage(view).then(({visitedViews}) => {
        this.$router.push({
          path: "/cwgd/newCarInsuranceList",
        })
      })
    }
  },
};
</script>




